# - Config file for the @PACKAGE_UPPER_NAME@ package

set(@PACKAGE_UPPER_NAME@_VERSION "@VERSION@")
set(@PACKAGE_UPPER_NAME@_RUN_IN_MODULE_MODE ON CACHE INTERNAL "qt5 run in module mode")

set(_qt5_install_prefix ${CMAKE_CURRENT_LIST_DIR}/inst/lib/cmake)

if (NOT Qt5_FIND_COMPONENTS)
    set(Qt5_NOT_FOUND_MESSAGE "The Qt5 package requires at least one component")
    set(@PACKAGE_UPPER_NAME@_FOUND FALSE)
    return()
endif()

set(_Qt5_FIND_PARTS_REQUIRED)
if (Qt5_FIND_REQUIRED)
    set(_Qt5_FIND_PARTS_REQUIRED REQUIRED)
endif()
set(_Qt5_FIND_PARTS_QUIET)
if (Qt5_FIND_QUIETLY)
    set(_Qt5_FIND_PARTS_QUIET QUIET)
endif()

set(_Qt5_NOTFOUND_MESSAGE)

include(${_qt5_install_prefix}/Qt5/Qt5ModuleLocation.cmake)

foreach(module ${Qt5_FIND_COMPONENTS})
    find_package(Qt5${module}
        ${_Qt5_FIND_PARTS_QUIET}
        ${_Qt5_FIND_PARTS_REQUIRED}
        PATHS ${_qt5_module_paths} NO_DEFAULT_PATH
    )
    if (NOT Qt5${module}_FOUND)
        string(CONFIGURE ${_qt5_module_location_template} _expected_module_location @ONLY)

        if (Qt5_FIND_REQUIRED_${module})
            set(_Qt5_NOTFOUND_MESSAGE "${_Qt5_NOTFOUND_MESSAGE}Failed to find Qt5 component \"${module}\" config file at \"${_expected_module_location}\"\n")
        elseif(NOT Qt5_FIND_QUIETLY)
            message(WARNING "Failed to find Qt5 component \"${module}\" config file at \"${_expected_module_location}\"")
        endif()

        unset(_expected_module_location)
    endif()
endforeach()

if (_Qt5_NOTFOUND_MESSAGE)
    set(Qt5_NOT_FOUND_MESSAGE "${_Qt5_NOTFOUND_MESSAGE}")
    set(@PACKAGE_UPPER_NAME@_FOUND FALSE)
else()
    set(@PACKAGE_UPPER_NAME@_FOUND TRUE)
endif()
